package leetcode100;

/**
 * @author shkstart
 * @create 2022-11-29-22:50
 */
public class Meme10_3 {
    public boolean checkWon(int[][] board){
        int size = board.length;
        int sum = 0;

        //检查行的和
        for (int i = 0; i < size - 1; i++) {
            for (int j = 0; j < size; j++) {
                sum+=board[i][j];
            }
            if(sum== size){
                return  true;
            }
        }
        //检查列的和
        for (int i = 0; i < size - 1; i++) {
            for (int j = 0; j < size; j++) {
                sum+=board[j][i];
            }
            if(sum== size){
                return  true;
            }
        }
        //这里需要将sum清空，避免之前的循环造成影响
        sum = 0;
        //检查对角线的和
        for (int i = 0; i < size; i++) {
            sum+=board[i][i];
        }
        if(sum== size){
            return  true;
        }
        //检查副对角线的和
        for (int i = 0; i < size; i++) {
            sum+=board[i][size-i-1];
        }
        if(sum== size){
            return  true;
        }
        return  false;




    }
}
